//
//  ImageLabelSelectCell.m
//  QuXiang
//
//  Created by Duncan on 2020/7/2.
//  Copyright © 2020 NanHuaiZi. All rights reserved.
//

#import "ImageLabelSelectCell.h"

@implementation ImageLabelSelectCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubviews:[NSArray arrayWithObjects:self.leftImageView, self.titleLabel, self.rightImageView, nil]];
        [self masonryLayout];
    }
    return self;
}

#pragma mark ------- Lazy Methods -------

- (void)masonryLayout {
    [self.leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.contentView.mas_left).offset(kFragmemtFloat(15));
        make.size.mas_equalTo(kFragmemtFloat(28));
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.leftImageView.mas_right).offset(kFragmemtFloat(13));
    }];
    [self.rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView.mas_right).offset(-kFragmemtFloat(15));
        make.size.mas_equalTo(kFragmemtFloat(22));
    }];
}

- (UIImageView *)leftImageView {
    if (!_leftImageView) {
        _leftImageView = [[UIImageView alloc] init];
        _leftImageView.layer.masksToBounds = YES;
        _leftImageView.layer.cornerRadius = kFragmemtFloat(28) / 2;
    }
    return _leftImageView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel initWithTextColor:[UIColor blackColor] fontSize:16];
    }
    return _titleLabel;
}

- (UIImageView *)rightImageView {
    if (!_rightImageView) {
        _rightImageView = [[UIImageView alloc] init];
    }
    return _rightImageView;
}

@end
